\doxysection{x\+Queue\+Create }
\hypertarget{group__x_queue_create}{}\label{group__x_queue_create}\index{xQueueCreate@{xQueueCreate}}
queue. h 
\begin{DoxyPre}
QueueHandle\_t xQueueCreate(                           UBaseType\_t uxQueueLength,                           UBaseType\_t uxItemSize                       );
  \end{DoxyPre}


Creates a new queue instance, and returns a handle by which the new queue can be referenced.

Internally, within the Free\+RTOS implementation, queues use two blocks of memory. The first block is used to hold the queue\textquotesingle{}s data structures. The second block is used to hold items placed into the queue. If a queue is created using x\+Queue\+Create() then both blocks of memory are automatically dynamically allocated inside the x\+Queue\+Create() function. (see \href{http://www.freertos.org/a00111.html}{\texttt{http\+://www.\+freertos.\+org/a00111.\+html}}). If a queue is created using x\+Queue\+Create\+Static() then the application writer must provide the memory that will get used by the queue. x\+Queue\+Create\+Static() therefore allows a queue to be created without using any dynamic memory allocation.

\href{http://www.FreeRTOS.org/Embedded-RTOS-Queues.html}{\texttt{http\+://www.\+Free\+RTOS.\+org/\+Embedded-\/\+RTOS-\/\+Queues.\+html}}


\begin{DoxyParams}{Parameters}
{\em ux\+Queue\+Length} & The maximum number of items that the queue can contain.\\
\hline
{\em ux\+Item\+Size} & The number of bytes each item in the queue will require. Items are queued by copy, not by reference, so this is the number of bytes that will be copied for each posted item. Each item on the queue must be the same size.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
If the queue is successfully create then a handle to the newly created queue is returned. If the queue cannot be created then 0 is returned.
\end{DoxyReturn}
Example usage\+: 
\begin{DoxyPre}
struct AMessage
\{
   char ucMessageID;
   char ucData[ 20 ];
\};

void vATask( void *pvParameters )
\{
QueueHandle\_t xQueue1, xQueue2;

   // Create a queue capable of containing 10 uint32\_t values.
   xQueue1 = xQueueCreate( 10, sizeof( uint32\_t ) );
   if( xQueue1 == 0 )
   \{
    // Queue was not created and must not be used.
   \}

   // Create a queue capable of containing 10 pointers to AMessage structures.
   // These should be passed by pointer as they contain a lot of data.
   xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
   if( xQueue2 == 0 )
   \{
    // Queue was not created and must not be used.
   \}

   // ... Rest of task code.
\}
\end{DoxyPre}
 